package com.mg.plugin.agrometeorology.entity;

import com.mg.plugin.agrometeorology.common.StationDataType;

public class StationData {
    private String stationId;
    private String date;
    private float lat;
    private float lon;
    private float rain;
    private float wtem;
    private float temp;
    private float minTemp;
    private float maxTemp;
    private float oldTemp;
    private float oldRain;
    private float humidity;
    private float sunshine;

    public StationData(String data, int realStationIndex, int realDateIndex, int realRainIndex, int realTempIndex, StationDataType ostrinia) {
        String[] elements = data.split(",");
        if (ostrinia == StationDataType.OSTRINIA) {
            this.stationId = elements[realStationIndex];
            this.date = elements[realDateIndex];
            this.rain = Float.parseFloat(elements[realRainIndex]);
            this.temp = Float.parseFloat(elements[realTempIndex]);

            //todo 水热系数计算
            this.wtem = rain / temp;
        }
        if (ostrinia == StationDataType.APHIS_GLYCINES) {
            this.stationId = elements[realStationIndex];
            this.date = elements[realDateIndex];
            this.rain = Float.parseFloat(elements[realRainIndex]);
            this.oldRain = Float.parseFloat(elements[realTempIndex]);
        }
    }

    public StationData(String data, int stationIndex, int dateIndex, int rainIndex, int realOldRainIndex, int realTempIndex, int realOldTempIndex, int realHumidityIndex, StationDataType stationDataType) {
        String[] elements = data.split(",");
        if (stationDataType == StationDataType.EXSEROHILUM) {
            this.stationId = elements[stationIndex];
            this.date = elements[dateIndex];
            this.rain = Float.parseFloat(elements[rainIndex]);
            this.oldRain = Float.parseFloat(elements[realOldRainIndex]);
            this.temp = Float.parseFloat(elements[realTempIndex]);
            this.temp = Float.parseFloat(elements[realOldTempIndex]);
            this.humidity = Float.parseFloat(elements[realHumidityIndex]);
        }
        if (stationDataType == StationDataType.RICE_BLAST) {
            this.stationId = elements[stationIndex];
            this.date = elements[dateIndex];
            this.temp = Float.parseFloat(elements[rainIndex]);
            this.minTemp = Float.parseFloat(elements[realOldRainIndex]);
            this.rain = Float.parseFloat(elements[realTempIndex]);
            this.humidity = Float.parseFloat(elements[realOldTempIndex]);
            this.sunshine = Float.parseFloat(elements[realHumidityIndex]);
        }
    }

    public StationData(String data, int realStationIndex, int realDateIndex, int realRainIndex, int realTempIndex, int realHumidityIndex, int realMaxTempIndex, StationDataType stationDataType) {
        String[] elements = data.split(",");
        if (stationDataType == StationDataType.OSTRINIA) {
            String rh = elements[realHumidityIndex];
            if(null == rh || rh.equals("null")){
                rh = "0";
            }
            this.stationId = elements[realStationIndex];
            this.date = elements[realDateIndex];
            this.rain = Float.parseFloat(elements[realRainIndex]);
            this.temp = Float.parseFloat(elements[realTempIndex]);
            this.humidity = Float.parseFloat(rh);
            this.maxTemp = Float.parseFloat(elements[realMaxTempIndex]);
        }
    }

    public StationData() {

    }

    public StationData(String stationId) {
        this.stationId = stationId;
    }

    public String getStationId() {
        return stationId;
    }

    public void setStationId(String stationId) {
        this.stationId = stationId;
    }

    public String getDate() {
        return date;
    }

    public void setDate(String date) {
        this.date = date;
    }

    public float getRain() {
        return rain;
    }

    public void setRain(float rain) {
        this.rain = rain;
    }

    public float getWtem() {
        return wtem;
    }

    public void setWtem(float wtem) {
        this.wtem = wtem;
    }

    public float getTemp() {
        return temp;
    }

    public void setTemp(float temp) {
        this.temp = temp;
    }

    public float getOldTemp() {
        return oldTemp;
    }

    public void setOldTemp(float oldTemp) {
        this.oldTemp = oldTemp;
    }

    public float getOldRain() {
        return oldRain;
    }

    public void setOldRain(float oldRain) {
        this.oldRain = oldRain;
    }

    public float getHumidity() {
        return humidity;
    }

    public void setHumidity(float humidity) {
        this.humidity = humidity;
    }

    public float getMinTemp() {
        return minTemp;
    }

    public void setMinTemp(float minTemp) {
        this.minTemp = minTemp;
    }

    public float getSunshine() {
        return sunshine;
    }

    public void setSunshine(float sunshine) {
        this.sunshine = sunshine;
    }

    public float getMaxTemp() {
        return maxTemp;
    }

    public void setMaxTemp(float maxTemp) {
        this.maxTemp = maxTemp;
    }

    public float getLat() {
        return lat;
    }

    public void setLat(float lat) {
        this.lat = lat;
    }

    public float getLon() {
        return lon;
    }

    public void setLon(float lon) {
        this.lon = lon;
    }
}


